#include <vector>
#include <string>
#include <unordered_map>
#include <iostream>
#include <time.h>
using namespace std;
class Solution
{
public:
    void sortColors(vector<int> &nums)
    {
        int lend = 0, rhead = nums.size() - 1;
        for (int i = 0; i <= rhead; ++i)
        {
            while (i <= rhead && nums[i] == 2)
                swap(nums[i], nums[rhead--]);
            if (nums[i] == 0)
                swap(nums[i], nums[lend++]);
        }
    }
};